package com.zhiche.lisa.bms.controller.psup;


import com.zhiche.lisa.bms.pojo.vo.psup.PsupSdFleetVO;
import com.zhiche.lisa.bms.service.psup.PsupSdFleetService;
import com.zhiche.lisa.core.supports.BaseException;
import com.zhiche.lisa.core.supports.RestfulResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 人送车队数据 前端控制器
 * </p>
 *
 * @author linbao
 * @since 2019-06-18
 */
@RestController
@RequestMapping("/psupSdFleet")
@Api(description = "人送车队数据", tags = "人送车队数据")
@Slf4j
public class PsupSdFleetController extends PsupSdBaseController {

    @Autowired
    private PsupSdFleetService psupSdFleetService;

    /**
     * 获取所有的人送车队
     *
     * @return
     */
    @GetMapping(value = "/getSdFleetList")
    @ApiOperation(value = "获取所有的人送车队", notes = "获取所有的人送车队", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiResponses({@ApiResponse(code = 0, message = "success", response = PsupSdFleetVO.class),
            @ApiResponse(code = -1, message = "系统异常")})
    public RestfulResponse<List<PsupSdFleetVO>> getSdFleetList() {
        log.info("PsupSdFleetController.getSdFleetList");
        RestfulResponse<List<PsupSdFleetVO>> resultResponse = getSuccessResponse();
        try {
            resultResponse.setData(psupSdFleetService.getSdFleetList());
        } catch (BaseException e) {
            log.error("PsupSdFleetController.getSdFleetList error:{}", e);
            setBaseExceptionResponse(resultResponse, e.getMessage());
        } catch (Exception e) {
            log.error("PsupSdFleetController.getSdFleetList error:{} ", e);
            setErrorResponse(resultResponse);
        }
        return resultResponse;
    }
}

